﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HttpClient
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        string baseUrl = "http://localhost:8080/";

        private void btnGet_Click(object sender, EventArgs e)
        {
            tbText.Text = "";
            
            string subUrl = "getdata";
            //将接口传入，这个HttpUitls的类，有兴趣可以研究下，也可以直接用就可以，不用管如何实现。
            string getJson = HttpUitls.Get(baseUrl +  subUrl);
            tbText.Text = getJson;
            //Console.Write(getJson);
            //JsonConvert.SerializeObject(listjson);
            //JSON.parse(json);
            //Console.ReadKey();
        }

        private void btnPost_Click(object sender, EventArgs e)
        {
            string subUrl = "postdata";
            //SysUser sysUser = new SysUser(100, "wky", 32);
            string jsonStr = JsonHelper.ToJSON(new SysUser(100, "wky", 32));
            string returnStr = HttpUitls.Post(baseUrl + subUrl, jsonStr, "");
            tbText.Text = returnStr;
        }
    }
}
